package com.board.exception;

import com.board.util.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class HandlerException {


    @ExceptionHandler(BoardException.class)
    public Result handlerException(BoardException boardException){
        return Result.fail(boardException.getCode(), boardException.getMessage());
    }

    @ExceptionHandler(Throwable.class)
    public Result handlerException(Throwable throwable){
        throwable.printStackTrace();
        return Result.fail(500, throwable.getMessage());
    }


}
